//== SAGITTARIUS ============================================================================

//== BEGINNING OF CODE ===============================================================

//== INCLUDES ========================================================================

#include "sagittarius/core/SagittariusCore.hpp"

#include "sagittarius/unicode/SimpleUnicodeString.hpp"

namespace Sagittarius
{
    
    ///SimpleUnicodeString
    void SimpleUnicodeString::FromStream(std::istream& is)
    {
        clear();
        reserve(512);
        int i=0;
        try {
            while(1)
            {
                push_back(SimpleUChar_FromStream(is));
                ++i;
                if(i%512 == 0)
                    reserve(capacity()+512);
            }
        } catch(SimpleUnicodeChar_EOF)
        {
            //end of file: do nothing
        } catch(Exception e) {
            std::stringstream s;
            s << "Error converting character " << i+1 << ": " << e.getDescription();
            SAGITTARIUS_THROW(SanityCheckException, s.rdbuf()->str(), "SimpleUnicodeString::FromStream");
        }
    }
    
    std::ostream& operator<<(std::ostream& os, const SimpleUnicodeString& str)
    {
        os << str.ToStdString();
        //os << str.ToCodepointString();
        return os;
    }
    
} //namespace Sagittarius
